package com.onec.service.api.dto.request.gateway;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.onec.service.api.content.PatternUtil;
import com.onec.service.api.dto.request.BaseRequest;
import com.onec.service.api.utils.group.*;
import com.onec.service.api.utils.group.trade.ApiPayGroup;
import com.onec.service.api.utils.group.trade.HtmlPayGroup;
import com.onec.service.api.utils.group.trade.QueryGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 业务请求公共参数：
 *
 * @author onec
 */
@Data
@EqualsAndHashCode(callSuper=false)
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class BizContent extends BaseRequest {

    /**
     * (机构)商户号
     */
    @NotNull(message = "请求服务不可为空", groups = {MerchantRegisterGroup.class})
    @Length(min = 12, max = 36, message = "请求服务介于12-36之间", groups = {MerchantRegisterGroup.class})
    public String service;

    /**
     * (机构)商户号
     */
    @NotNull(message = "商户编号不可为空", groups = {MerchantRegisterGroup.class})
    @Length(min = 5, max = 12, message = "商户编号介于5-12之间", groups = {MerchantRegisterGroup.class})
    public String outCode;
    /**
     * (机构)商户号
     */
    @NotNull(message = "商户编号不可为空", groups = {MerchantOpenGroup.class, MerchantModifyGroup.class})
    @Length(min = 5, max = 12, message = "商户编号介于5-12之间", groups = {MerchantOpenGroup.class})
    public String merchantNo;
    /**
     * (机构)商户简称
     */
    @NotNull(message = "商户名称不可为空", groups = {MerchantRegisterGroup.class})
    @Length(min = 5, max = 12, message = "商户名称介于5-12之间", groups = {MerchantRegisterGroup.class})
    public String merchantName;

    /**
     * 商户门店地址
     */
    @NotNull(message = "门店地址不可为空", groups = {MerchantRegisterGroup.class})
    @Length(min = 6, max = 20, message = "门店地址介于6-20之间", groups = {MerchantRegisterGroup.class})
    public String address;

    /**
     * 联行号
     */
    @NotNull(message = "联行号不可为空", groups = {MerchantRegisterGroup.class})
    public String bankCode;

    /**
     * 结算类型 :0对公，1对私
     */
    @NotEmpty(message = "结算类型格式有误", groups = {MerchantRegisterGroup.class})
    public String settleType;
    /**
     * 手机号
     */
    @NotNull(message = "手机号不可为空", groups = {MerchantRegisterGroup.class, MerchantModifyGroup.class})
    @Pattern(regexp = PatternUtil.PHONE, message = "手机信息不合法", groups = {MerchantRegisterGroup.class, MerchantModifyGroup.class})
    public String phone;

    /**
     * 结算卡
     */
    @NotNull(message = "卡号不可为空", groups = {MerchantRegisterGroup.class, MerchantModifyGroup.class})
    public String cardNo;
    /**
     * 姓名
     */
    @NotNull(message = "姓名不可为空", groups = {MerchantRegisterGroup.class})
    //@Pattern(regexp = PatternUtil.REG_NAME, message = "姓名格式有误", groups = {MerchantRegisterGroup.class})
    public String name;
    /**
     * 身份号
     */
    @NotNull(message = "身份证信息不可为空", groups = {MerchantRegisterGroup.class})
    @Pattern(regexp = PatternUtil.REG_ID_CARD,
            message = "身份信息不合法", groups = {MerchantRegisterGroup.class})
    public String idCard;
    /**
     *
     */
    @NotNull(message = "省编码不为空", groups = {MerchantRegisterGroup.class})
    public String province;
    /**
     *
     */
    @NotNull(message = "市编码不为空", groups = {MerchantRegisterGroup.class})
    public String city;
    /**
     * 身份号
     */
    @NotNull(message = "县编码不为空", groups = {MerchantRegisterGroup.class})
    public String country;

    /**
     * 交易描述
     */
    public String message;


    @NotNull(message = "交易费率不可为空", groups = {MerchantOpenGroup.class})
    public String rate;

    @NotNull(message = "固定值不可为空", groups = {MerchantOpenGroup.class})
    public String fee;

    public String product;

    @NotNull(message = "业务编号不可为空", groups = {MerchantOpenGroup.class})
    public String businessNo;

    /**
     * 机构订单号
     */
    @NotNull(message = "交易订单号不可为空", groups = {HtmlPayGroup.class, QueryGroup.class})
    @Length(min = 8, max = 32, message = "交易订单号介于8-32之间", groups = {HtmlPayGroup.class})
    public String externalNum;

    /**
     * 通道订单号
     */
    public String tradeNum;

    /**
     * 平台流水号
     */
    public String serialNum;
    /**
     * 交易金额
     */
    @Pattern(regexp = PatternUtil.AMOUNT_, message = "交易金额不合法")
    @NotNull(message = "交易金额不可为空", groups = {HtmlPayGroup.class})
    public String amount;

    /**
     * 姓名
     */
    @Pattern(regexp = PatternUtil.REG_NAME, message = "姓名格式有误", groups = {HtmlPayGroup.class})
    public String userName;

    /**
     * 交易金额
     */
    @Pattern(regexp = PatternUtil.REG_URL, message = "同步回调地址URL不合法")
    public String frontUrl;

    @Pattern(regexp = PatternUtil.REG_URL, message = "异步回调地址URL不合法", groups = {HtmlPayGroup.class})
    @NotNull(message = "异步通知地址不可为空", groups = {HtmlPayGroup.class})
    public String callBackUrl;
    /**
     * 产品信息
     */
    public String productInfo;

    @NotNull(message = "城市编码不可为空", groups = {ApiPayGroup.class})
    public String areaCode;

    public String mcc;

    /**
     * 代理编号
     */
    public String agentNo;

}
